Database Maintenance

Description

In this lesson, you learn about several database maintenance tasks that you can perform to keep your database updated, backed up, and secure.

Updating Indexes

Alpha Anywhere maintains and updates indexes, and adjusts their ordered list of selected keys, whenever you add, change, or delete records. However, certain events can corrupt your indexes; for example, if you improperly exit Alpha Anywhere, such as turning off your computer while Alpha Anywhere is running, or if a power failure occurs while Alpha Anywhere is updating an index. When an index becomes corrupted, you might notice that records do not appear as expected. For example, a record that you can see in a default browse does not appear on a report. Some database problems can be traced to corrupted or out-to-date indexes. If you have any doubt about the integrity of your indexes, you should update them manually. Selecting Update Indexes to rebuild the indexes associated with a table is likely to fix the problem. For a set, Update Indexes updates the indexes for all the tables in the set. To update or rebuild an index:

  1. Right-click on a table in the Control Panel, and select Update Indexes from the right-click menu, or select Table > Update Indexes from the menu bar. If you receive index file error messages while working with a table, or if some of the records appear to be missing or duplicated, you can use the Define Indexes option to rebuild the index.

  2. Right-click on a table in the Control Panel, and select Define Indexes from the right-click menu, or select Table > Define Indexes from the menu bar. The Index Builder appears.

  3. Click Build. An Alpha Anywhere message appears.

    images/rebuildIndexes.gif
  4. Click Yes. Alpha Anywhere rebuilds the indexes.

For larger tables, a status bar displays the progress as the indexes are updated. Indexes for smaller tables are rebuilt so quickly that no status bar appears.

Backing up the Database

To back up a database:

  1. Open the Control Panel.

  2. Select Tools > Backup/Restore Database > Backup Database. The Backup dialog box appears.

    images/UG_Backup_dialog_box.gif
  3. Select the drive and directory for the backup files. Backup files are best saved separately from the working files, such as on a CD, in a zip file, or in some other remote location.

  4. Check Compact Database before Backup.

  5. Click Save Settings. The Save Settings dialog box appears. Picture

    • After you back up your database files for the first time and save your settings, Alpha Anywhere advises that you can use a one-step backup in the future.

    images/backupSaveSettings.gif
  6. Click OK.

  7. In the Backup dialog box, click Backup. A Backup confirmation window appears.

  8. Click View the Backup Log to see the location and date of backed up files.

  9. Click Close.

Creating Periodic Backups

In the next procedure, you provide an Alpha Anywhere setting to create weekly database backups. If your database gets very frequent use, you might want to back it up daily. To create periodic backups:

  1. Open the Control Panel.

  2. Select View > Settings > Database > Backup Database.

  3. The Settings dialog box appears.

    images/backupViewSettings.gif
  4. Check Require periodic backups every and enter "7" days. You can specify whether Alpha Anywhere issues a backup reminder or makes performing a backup a requirement for use.

Undeleting Records

To undelete records:

  1. Right click on the table in the Table/Set tab of the Control Panel.

  2. Select Utilities > Undelete Records....

  3. Optionally check Mark records that are undeleted. This gives you the opportunity to easily identify the records that you have undeleted.

  4. Optionally select Range of records and enter a Start Record # and End Record #.

  5. Click OK to undelete the selected records.

    images/Undelete_Records.gif

Compacting the Database

When designing forms and reports, the size of the data dictionaries, the DDD and SET files, grows over time as you continue to make edits to the objects in your database. It is a good practice to periodically remove the extra bulk by compacting the database. The Compact Database command packs all tables and compresses the data dictionary files. You can check the size of the database before and after compacting to see the file size reduction. You can also select to compact the database when you back it up. To compact a database:

  1. Open the Control Panel.

  2. Close all Forms, Operations, and any dialog that may have a table open. Alpha Anywhere cannot perform a compact operation on tables with open Forms.

  3. Select File > Database Compact. Alpha Anywhere completes the Compact Database Operation.

Packing Tables

The Pack Operation removes deleted records from the database and compresses memo fields. You should pack tables periodically so that they take up less space and to help database operations run more quickly. After packing a table, you can no longer undelete records. Also, if you select Compact Database before Backup in the Backup dialog box, Alpha Anywhere packs the records and you cannot undelete them. To pack a database:

  1. Open the Control Panel.

  2. Right-click on a table, and select Pack from the right-click menu. An Alpha Anywhere warning appears. Picture

    images/packWarning.gif
  3. Click OK. A Pack confirmation window appears.

Restoring the Database

Alpha Anywhere lets you create a snapshot of your database, so that you can go back to a particular database backup. For example, the backup you made on June 25th, 2000 at 4.35 p.m. You can select the specific database backup to restore, or select to back up and restore individual files. To restore an open database:

  1. Open the Control Panel.

  2. Select Tools > Backup/Restore Database > Restore Database. The Restore Database dialog box appears. Picture

    • Alpha Anywhere displays the backup files for the current database.

    images/restoreDB.gif
  3. Select the backup files to restore, and click Restore.

To restore any backed up database:

  1. Close any open database, and select Tools > Restore Database from the Alpha Anywhere menu bar.

  2. Use the Restore Database dialog box to specify the database files to restore.

  3. Alternatively, you can use the Alpha Anywhere Welcome screen to select a database to restore.

    images/restoreDB2.gif

Database Security

Alpha Anywhere has a security framework that lets you create a Master Password for a Database Administrator, and define separate or shared user accounts and passwords. To setup database security:

  1. Open the database.

  2. Select Tools > Security > Set Database Password. The Set Database Master Password dialog box appears.

    • If you define individual user accounts, you specify the user name, password, and an optional startup script for when that user logs on. This also lets you define different startup menus for each application user.

    images/UG_Security_Master_Password.gif
  3. Enter and verify a Master password, and click OK. A Master Password confirmation window appears. Picture

    images/masterPasswordConfirm.gif
  4. Click OK. If you specify that a database has a password, Alpha Anywhere displays the Password screen when you open that database.

    images/login.gif
  5. Select Tools > Security, to select or change the following security options.

    • Change Master Password

    • Change Security Settings

    • Remove Database Password

    • Customize Logon Dialog

    • Encrypt/Decrypt Tables

    • Define Users and Groups

  6. Select Define Users and Groups to specify the group to which each user belongs.

    images/usersGroups.gif

For example, you can specify that Tom, Fred, and Harry are members of the Accounting group. The user account information is stored in a User Accounts File. The User Accounts File can either be specific to a particular database, or you can specify a shared User Account File so that each of your databases has the same user and group information. For more detailed information about setting up security for your Alpha Anywhere application, see Startup Event Sequence and Setting Up Database Security.

Encryption

Once you have set a Master Password for a database, you can encrypt individual tables in the database. Once a table has been encrypted, you can use it normally within the database, but you will not be able to open the database in other contexts, such as with Microsoft Excel, or use it with other software programs that can read DBF files. To encrypt database tables:

  1. With the database open, select Tools > Security > Encrypt/Decrypt Tables. The Encrypt/Decrypt Tables dialog box appears.

    images/encryptTables.gif
  2. Select the tables to encrypt, and click Apply.

Summary

In this lesson you learned about updating and rebuilding indexes, packing and compacting your database, backing up and restoring your database, and providing database security using password protection and table encryption. See Action Scripting to learn about creating Action Scripts and how you can use them to customize your database application.

See Also